package com.imageflowpro.image_flow_pro.controller.admin;

import com.imageflowpro.image_flow_pro.service.IMediaImageService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("adminMediaImageController")
@RequestMapping("/admin/minio")
@Slf4j
public class MediaImageController {

    @Autowired
    private IMediaImageService iMediaImageService;

    @GetMapping("/downloadImage/{orderId}")
    public ResponseEntity<InputStreamResource> downloadImages(@PathVariable String orderId) {
        return iMediaImageService.adminDownloadImages(orderId);
    }

    @GetMapping("/WXDownloadImage/{orderId}/{token}")
    public ResponseEntity<InputStreamResource> WXDownloadImages(@PathVariable String orderId,@PathVariable String token) {

        return iMediaImageService.adminWXDownloadImages(orderId,token);
    }

    @GetMapping("/getImage/{imageId}")
    public void getImageById(HttpServletResponse response, @PathVariable("imageId") Long imageId){
        iMediaImageService.getImageById(response,imageId);
    }
}
